const service = require("../../module/service.js");
const get_from = require("../../module/service.js").get_from;
Page({
  data:{
    listmessage:[]
  },
  // onLoad(){
    //TODO: 可以完善成有新订单才重新加载
    onShow(){
    get_from('user/orderlist', {user_id: getApp().globalData.userInfo.user_id}).then((res)=>{
      this.setData({
        listmessage:res.data
      });
      console.log(this.data.listmessage);
    }).catch(()=>{
      wx.showToast({
        title: '数据请求错误',
        icon:'error',
        duration:500
      })
    })
  },
  //查看订单详情，转detail页面
  showDetail(e){
    let index = e.currentTarget.dataset.index;
    let order_num = '';
    order_num = this.data.listmessage[index].order_num;
    console.log(order_num);
    wx.navigateTo({
      url: '/pages/detail/detail?order_num=' + order_num,
    });
  },
  //也是查看订单详情，转detail页面
  handleTake(e){
    let index = e.currentTarget.dataset.index;
    let order_num = '';
    order_num = this.data.listmessage[index].order_num;
    wx.navigateTo({
      url: '/pages/detail/detail?order_num=' + order_num,
    });
  }
})